# -*- coding: utf-8 -*-
# @Time    : 2021/11/9 22:50
# @Author  : super

import pymysql
import random

if __name__ == '__main__':
    conn = pymysql.connect(host = 'localhost', port = 3306, user = 'root', password = '123456', database = 'flask_demo',
	                       charset = 'utf8')

    cursor = conn.cursor()

    sql = "DELETE FROM `user` WHERE id = %s;"

    try:
        row_number = cursor.execute(sql, [2])

        conn.commit()
        if row_number > 0:
            print("删除成功~")
        else:
            print("删除失败~")
    except Exception as e:
        conn.rollback()
        print(e)
    finally:
        cursor.close()
        conn.close()

